<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #banner{
            width: 100%;
            height: 200px;
            border:solid 1px #666;
        }

        #banner2{
            width: 100%;
            height: 200px;
            border:solid 1px rgb(114, 26, 26);
        }

        #c{
            color: #4969d3;
        }
        html, body, #root{
            width: 100%;
            height: 100%;
            overflow: hidden;
        }
    </style>
</head>
<body>
    <div id="root">
        <div id="banner">

        </div>
        <a href="http://www.atguigu.com">尚硅谷</a>
        <input type="text">
    </div>


    <script>
        //获取元素
        let banner = document.querySelector('#banner');
        let banner2 = document.querySelector('#banner2');
        let root = document.querySelector('#root');
        let input = document.querySelector('input');

        //绑定事件
        banner.ontouchstart = function(e){
            //改变 div 的背景颜色
            this.style.background = 'rgb(201, 72, 72)';
            //
            // e.preventDefault();
        }
        
        //根元素 绑定事件
        root.addEventListener("touchstart", function(e){
            //阻止默认行为
            e.preventDefault();
        });

        //获取 a 元素
        let link = document.querySelector('a');
        link.addEventListener("touchstart", function(e){
            e.stopPropagation();
        });

        input.addEventListener('touchstart', function(e){
            e.stopPropagation();
        })

    </script>
</body>
</html>